package com.ailink.design.pattern.singleton;

/**
 * Created by Administrator on 2018/9/19
 */
public class HungrySingleton {
//    private final static HungrySingleton hungrySingleton = new HungrySingleton();
    private final static HungrySingleton hungrySingleton;

    static {
        hungrySingleton = new HungrySingleton();
    }

    private HungrySingleton() {
//        if (hungrySingleton == null) {
//            throw new RuntimeException("单例模式禁止反射调用");
//        }
    }

    public static HungrySingleton getInstance() {
        return hungrySingleton;
    }

    public static void main(String[] args) {
        System.out.println(HungrySingleton.getInstance());
        System.out.println(HungrySingleton.getInstance());
    }
}
